<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="开始时间" prop="startDate">
        <el-date-picker
          clearable
          v-model="queryParams.startDate"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择开始时间"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="endDate">
        <el-date-picker
          clearable
          v-model="queryParams.endDate"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择结束时间"
        >
        </el-date-picker>
      </el-form-item>
<!--      <el-form-item label="板块">-->
<!--        <el-select @change="handleQuery" v-model="queryParams.postType" placeholder="请选择">-->
<!--          <el-option label="素人改造" value="6"></el-option>-->
<!--          <el-option label="不剃发hot" value="5"></el-option>-->
<!--          <el-option label="头皮效果" value="4"></el-option>-->
<!--          <el-option label="极粉评论" value="8"></el-option>-->
<!--          <el-option label="武林秘籍" value="7"></el-option>-->
<!--        </el-select>-->
<!--      </el-form-item>-->

      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
        >导出</el-button
        >
      </el-form-item>
    </el-form>

<!--    <el-row :gutter="10" class="mb8">-->
<!--      <right-toolbar-->
<!--        v-model:showSearch="showSearch"-->
<!--        @queryTable="getList"-->
<!--      ></right-toolbar>-->
<!--    </el-row>-->

    <el-table
      v-loading="loading"
      :data="hairTriggerEventList"
    >
      <el-table-column label="板块" align="center" prop="postTypeName" />
      <el-table-column label="分享量" align="center" prop="shareNum" />
      <el-table-column label="新客量（所有）" align="center" prop="newCustomerNum" />
      <el-table-column label="新客量（纯内容）" align="center" prop="newCustomerContentNum" />
      <el-table-column label="平均停留时长" align="center" prop="svgStayTime">
        <template #default="scope">
          {{ parseConvertTime(scope.row.svgStayTime) }}
        </template>
      </el-table-column>
      <el-table-column label="3s跳失量" align="center" prop="enterThreeSecondsPersonNum" />
      <el-table-column label="10s跳失量" align="center" prop="enterTenSecondsPersonNum" />
      <el-table-column label="跳出当日2次访问量" align="center" prop="twiceDayPersonNum" />
      <el-table-column label="跳出3日2次访问量" align="center" prop="threeDayPersonNum" />
      <el-table-column label="进入AI换发用户量" align="center" prop="aiChangeHairPersonNum" />
      <el-table-column label="AI注册量" align="center" prop="aiRegisterPersonNum" />
      <el-table-column label="进入咨询补发师用户量" align="center" prop="consultTeacherNum" />
      <el-table-column label="咨询注册量" align="center" prop="consultTeacherRegisterPersonNum" />
    </el-table>

<!--    <pagination-->
<!--      v-show="total > 0"-->
<!--      :total="total"-->
<!--      v-model:page="queryParams.pageNum"-->
<!--      v-model:limit="queryParams.pageSize"-->
<!--      @pagination="getList"-->
<!--    />-->

  </div>
</template>

<script setup name="HairTriggerEvent">
import {
  getPostPlateShareList
} from "@/api/business/operation";
import {parseConvertTime} from "@/utils/ruoyi";

const { proxy } = getCurrentInstance();

const hairTriggerEventList = ref([]);
const open = ref(false);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const data = reactive({
  form: {},
  queryParams: {
    // startDate: proxy.parseTime(new Date(), "{y}-{m}-{d}"),
    // endDate: proxy.parseTime(new Date(), "{y}-{m}-{d}"),
    nickName: undefined,
    postType: "6",
    // queryUser: "1",
    salesDirector: undefined,
    eventValue: undefined,
  },
});

const { queryParams, form, rules } = toRefs(data);

/** 查询用户触发事件记录列表 */
function getList() {
  loading.value = true;
  getPostPlateShareList(queryParams.value).then((response) => {
    hairTriggerEventList.value = response.data;
    // total.value = response.data.total;
    loading.value = false;
  });
}


/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");

  queryParams.value = {
    pageNum: 1,
    pageSize: 15,
    userId: null,
    type: null,
    startDate: null,
    endDate: null,
    nickName: null,
    salesDirector: null,
    eventValue: null,
  };
  handleQuery();
}





/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "business/operation/exportPlateShareList",
    {
      ...queryParams.value,
    },
    `hairTriggerEvent_${new Date().getTime()}.xlsx`
  );
}

getList();
</script>
